<template>

    <div class="top" :class="{'bg':headerActive}">
        <van-icon name="wap-nav" color="#fff" class="icon"/>
        <div class="searchbox">
            <span class="s1">G</span>
            <div class="box">
                <van-search v-model="value" clearable placeholder="请输入搜索关键词" class="box2" />
            </div>
        </div>
        <van-icon name="manager" color="#fff"  class="icon" @click="$router.push('/login')"/>
    </div>

   
</template>

<script>
    export default {
        data() {
            return {
                value: '',
                headerActive: false
             };
        },
        methods:{
            changeBg(){
                let scollTop = window.pageXOffset || document.documentElement.scrollTop || document.body.scrollTop
                scollTop > 100 ? this.headerActive = true : this.headerActive = false
            }
        },
        mounted(){
            window.addEventListener("scroll",this.changeBg)
        }

    }
</script>

<style lang="scss" scoped>
.top{
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    justify-content: space-between;
    height: 100px;
    z-index: 998;    
    width: 100%;
    padding: 0 30px;
    box-sizing: border-box;
    align-items: center;
}
.icon{
    font-size: 50px;
}
.searchbox{
    display: flex;
    background-color: #fff;
    border-radius: 40px;
    padding: 0 37.5px;
    align-items: center;
    width: 100%;
    margin: 0  10px;
}
.s1{
    display: inline-block;
    font-size: 40px;
    font-weight: 700;
    color: red;
    padding-right: 10px;
    border-right: 1px solid #000;
}
.van-search{
    padding: 0;
}
.box{
    width: 100%;
    background-color: #fff;
}
.box2 div{
    background-color: #fff;
}

.bg{
    background-color: #f63515;
}
</style>